package com.example.springboot.constant;

public class ElasticSearchConstants {
    //jdk13以上才能用的代码块语法。
    public static final String CREATE_INDEX_AND_MAPPING = """
            {
              "settings": {
                "analysis": {
                  "analyzer": {
                    "my_analyzer": {
                      "tokenizer": "ik_max_word",
                      "filter": ["py"]
                    }
                  },
                  "filter": {
                    "py": {
                      "type": "pinyin",
                      "keep_full_pinyin": false,
                      "keep_joined_full_pinyin": true,
                      "keep_original": true,
                      "limit_first_letter_length": 16,
                      "remove_duplicated_term": true,
                      "none_chinese_pinyin_tokenize": false
                    }
                  }
                }
              },
              "mappings": {
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "author_id": {
                    "type": "integer"
                  },
                  "category_id": {
                    "type": "integer"
                  },
                  "published_time": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss"
                  },
                  "status": {
                    "type": "integer"
                  },
                  "views": {
                    "type": "integer"
                  },
                  "likes": {
                    "type": "integer"
                  },
                  "collect_count": {
                    "type": "integer"
                  },
                  "article_type": {
                    "type": "integer"
                  },
                  "cover": {
                    "type": "keyword"
                  },
                  "title": {
                    "type": "text",
                    "analyzer": "my_analyzer",
                    "search_analyzer": "ik_smart",
                    "fields": {
                      "suggest": {
                        "type": "completion",
                        "analyzer": "my_analyzer"
                      }
                    }
                  },
                  "tags": {
                    "type": "text",
                    "analyzer": "my_analyzer",
                    "search_analyzer": "ik_smart",
                    "fields": {
                      "suggest": {
                        "type": "completion",
                        "analyzer": "my_analyzer"
                      }
                    }
                  },
                  "summary": {
                    "type": "text",
                    "analyzer": "my_analyzer",
                    "search_analyzer": "ik_smart",
                    "fields": {
                      "suggest": {
                        "type": "completion",
                        "analyzer": "my_analyzer"
                      }
                    }
                  },
                  "nickname": {
                    "type": "keyword"
                  }
                }
              }
            }
            """;
    public static final String CREATE_SEARCH_SUGGESTION_INDEX_AND_MAPPING = """
            {
              "settings": {
                "analysis": {
                  "analyzer": {
                    "my_analyzer": {
                      "tokenizer": "ik_max_word",
                      "filter": ["py"]
                    }
                  },
                  "filter": {
                    "py": {
                      "type": "pinyin",
                      "keep_full_pinyin": false,
                      "keep_joined_full_pinyin": true,
                      "keep_original": true,
                      "limit_first_letter_length": 16,
                      "remove_duplicated_term": true,
                      "none_chinese_pinyin_tokenize": false
                    }
                  }
                }
              },
              "mappings": {
                "properties": {
                  "id": {
                    "type": "keyword"
                  },
                  "search_suggest": {
                    "type": "keyword",
                    "fields": {
                      "suggest": {
                        "type": "completion",
                        "analyzer": "my_analyzer"
                      }
                    }
                  },
                  "last_time": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss"
                  },
                  "search_count": {
                    "type": "integer"
                  }
                }
              }
            }
            """;
    public static final String CREATE_USER_INDEX_AND_MAPPING = """
            {
              "settings": {
                "analysis": {
                  "analyzer": {
                    "my_analyzer": {
                      "tokenizer": "ik_max_word",
                      "filter": ["py"]
                    }
                  },
                  "filter": {
                    "py": {
                      "type": "pinyin",
                      "keep_full_pinyin": false,
                      "keep_joined_full_pinyin": true,
                      "keep_original": true,
                      "limit_first_letter_length": 16,
                      "remove_duplicated_term": true,
                      "none_chinese_pinyin_tokenize": false
                    }
                  }
                }
              },
              "mappings": {
                "properties": {
                  "id": {
                    "type": "keyword"
                  },
                  "username": {
                    "type": "keyword"
                  },
                  "nickname": {
                    "type": "text",
                    "analyzer": "my_analyzer",
                    "search_analyzer": "ik_smart",
                    "fields": {
                      "suggest": {
                        "type": "completion",
                        "analyzer": "my_analyzer"
                      }
                    }
                  },
                  "email": {
                    "type": "keyword"
                  },
                  "phone": {
                    "type": "keyword"
                  },
                  "create_time": {
                    "type": "date",
                    "format": "yyyy-MM-dd"
                  },
                  "update_time": {
                    "type": "date",
                    "format": "yyyy-MM-dd"
                  },
                  "avatar": {
                    "type": "keyword"
                  },
                  "all_views": {
                    "type": "integer"
                  },
                  "article_num": {
                    "type": "integer"
                  },
                  "fens_num": {
                    "type": "integer"
                  },
                  "ip_address": {
                    "type": "keyword"
                  },
                  "signature": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                  },
                  "birthday": {
                    "type": "keyword"
                  }
                }
              }
            }

            """;
    public static final String CREATE_PRODUCT_INDEX_AND_MAPPING = """
            {
              "settings": {
                "analysis": {
                  "analyzer": {
                    "my_analyzer": {
                      "tokenizer": "ik_max_word",
                      "filter": ["py"]
                    }
                  },
                  "filter": {
                    "py": {
                      "type": "pinyin",
                      "keep_full_pinyin": false,
                      "keep_joined_full_pinyin": true,
                      "keep_original": true,
                      "limit_first_letter_length": 16,
                      "remove_duplicated_term": true,
                      "none_chinese_pinyin_tokenize": false
                    }
                  }
                }
              },
              "mappings": {
                "properties": {
                  "id": {
                    "type": "keyword"
                  },
                  "title": {
                    "type": "text",
                    "analyzer": "my_analyzer",
                    "search_analyzer": "ik_smart",
                    "fields": {
                      "suggest": {
                        "type": "completion",
                        "analyzer": "my_analyzer"
                      }
                    }
                  },
                  "pic_path": {
                    "type": "keyword"
                  },
                  "original_price": {
                    "type": "keyword"
                  },
                  "sale_price": {
                    "type": "keyword"
                  },
                  "procity": {
                    "type": "keyword"
                  },
                  "realSales": {
                    "type": "keyword"
                  },
                  "nick": {
                    "type": "keyword"
                  },
                  "detail_url": {
                    "type": "keyword"
                  }
                }
              }
            }
            """;
}
